package com.awspaas.user.apps.processforsap.event;

import com.actionsoft.bpms.bo.engine.BO;
import com.actionsoft.bpms.bpmn.engine.core.delegate.ProcessExecutionContext;
import com.actionsoft.bpms.bpmn.engine.listener.ExecuteListener;
import com.actionsoft.bpms.bpmn.engine.listener.ListenerConst;
import com.actionsoft.bpms.bpmn.engine.model.run.delegate.ProcessInstance;
import com.actionsoft.sdk.local.SDK;

public class FI004CreateBeforeLoad extends ExecuteListener {
    @Override
    public void execute(ProcessExecutionContext processExecutionContext) throws Exception {
        ProcessInstance processInstance = processExecutionContext.getProcessInstance();
        if (processInstance != null) {
            String id = processInstance.getId();
            BO bo1 = SDK.getBOAPI().query("BO_EU_SAP_FIZC").detailByBindId(id);
            if (bo1 != null) {
                //BO表名
                String syzx = bo1.getString("SYZX");
                String boName = processExecutionContext.getParameterOfString(ListenerConst.FORM_EVENT_PARAM_BONAME);
                if ("其他".equals(syzx)) {
                    if ("BO_EU_SAP_FIZCLIST".equals(boName)) {
                        processExecutionContext.addFormHiddenPolicy("BO_EU_SAP_FIZCLIST", "IS_BG");//针对字段设置一个隐藏策略
                        processExecutionContext.addFormHiddenPolicy("BO_EU_SAP_FIZCLIST", "BGDW");//针对字段设置一个隐藏策略
                    }
                }
            }
        }
    }
}
